#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        int len = score.size();
        vector<string> ret(len, "0");
        
        /* 找出最大、最小值 */
        int maxScore = *max_element(score.begin(), score.end());
        int minScore = *min_element(score.begin(), score.end());

        /* 根据最大、最小值分配空间 */
        int lenTmp = maxScore - minScore + 1;
        vector<int> tmp(lenTmp, -1);

        /* 将原始数组与临时数组进行映射，临时数组从大到小排列 */
        for (int idx = 0; idx < len; idx++) {
            tmp[score[idx] - minScore] = idx;
        }
        reverse(tmp.begin(), tmp.end());
        /* 将临时数组与排名字符串映射 */
        int value = 0;
        for (int idx = 0; idx < lenTmp; idx++) {
            if (tmp[idx] != -1) {
                GetScore(ret, tmp[idx], value);
                value++;
            }
        }
        return ret;
    }

    void GetScore(vector<string> &ret, int pos, int idx)
    {
        if (idx == 0) {
            ret[pos] = "Gold Medal";
        } else if (idx == 1) {
            ret[pos] = "Silver Medal";
        } else if (idx == 2) {
            ret[pos] = "Bronze Medal";
        } else {
            ret[pos] = to_string(idx + 1);
        }
    }
};

int main()
{
    Solution s;
    vector<int> score = {10,3,8,9,4};
    vector<string> ret = s.findRelativeRanks(score);

    for (auto ele : ret) {
        cout << ele << endl;
    }
    return 0;
}